<template>
	<view class="container">
		<image v-if="imageUrl" :src="imageUrl" mode="widthFix"></image>
		<view v-else class="image-placeholder"></view>
		<button @click="chooseAndPreviewImage">选择图片</button>
		<button @click="PreviewImage">预览图片</button>
		
		
					
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imageUrl: '',
				tempFilePaths:[]
			}
		},
		methods: {
			chooseAndPreviewImage() {
				uni.chooseImage({
					count: 3,
					sourceType: ['album', 'camera'],
					success: (res) => {
						this.tempFilePaths = res.tempFilePaths
						this.imageUrl = res.tempFilePaths[0]
					}
				})
			},
			PreviewImage() {
				uni.previewImage({
					current: this.tempFilePaths[0],
										urls: this.tempFilePaths,
										loop: true 

				})
				
			}
			
		}
	}
</script>

<style>
	body{
		margin: 0;
		background-image: url(/static/background/chenglong.jpg);
		background-repeat: no-repeat;
		background-position: center;
		background-attachment: fixed;
		background-size: cover;
	}
	button{
		margin: 5rpx;
		padding: 5rpx 65rpx;
		font-size: 1rem;
		background-color: hsl(74, 20%, 50%,50%);
		border-radius: 15rpx;
		font-weight: bold;
		backdrop-filter: blur(52rpx);
	}
	.container {
	margin-top: 200rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 100%;
		height: 100vh;
	}

	image {
		width: 200px;
		height: 450rpx;
		margin: 20rpx;
		border-radius: 15rpx;
		
	}
	.image-placeholder{
		
		width: 200px;
		height: 450rpx;
		margin: 20rpx;
		border-radius: 15rpx;
	}
	button:hover{
		background-color: hsl(74, 20%, 60%,50%);
	}
	button:active{
		background-color: hsl(74, 20%, 70%,50%);
	}
</style>